<template>
  <div>
    <div
      class="box"
      :style="{
        justifyContent: user.roles.includes('biz_supplier_admin')
          ? 'flex-start'
          : 'space-between',
      }"
    >
      <el-card
        class="a1"
        :style="{
          marginRight: user.roles.includes('biz_supplier_admin') ? '20px' : '0',
        }"
      >
        <div class="boc-item">
          <div class="fons">商品数量</div>
          <div class="tag">
            <el-tag
              class="cc"
              size="mini"
              v-if="!user.roles.includes('biz_supplier_admin')"
            >
              全平台</el-tag
            >
          </div>
        </div>
        <div class="box-it">{{ productNum }}</div>
        <!-- <div class="boc-item1">
          <div class="fons1">今日订单数</div>
          <div class="tag">10单</div>
        </div> -->
      </el-card>
      <el-card class="a1">
        <div class="boc-item">
          <div class="fons">订单总数</div>
          <div class="tag">
            <el-tag
              class="cc"
              size="mini"
              v-if="!user.roles.includes('biz_supplier_admin')"
            >
              全平台</el-tag
            >
          </div>
        </div>
        <div class="box-it">{{ orderNum }}</div>
        <!-- <div class="boc-item1">
          <div class="fons1">今日订单数</div>
          <div class="tag">10单</div>
        </div> -->
      </el-card>
      <el-card class="a1" v-if="!user.roles.includes('biz_supplier_admin')">
        <div class="boc-item">
          <div class="fons">订单总额</div>
          <div class="tag">
            <el-tag class="cc" size="mini"> 全平台</el-tag>
          </div>
        </div>
        <div class="box-it">
          {{ orderMoney }}
          <span style="font-size: 14px">元</span>
          |
          {{ jifenAmountTotal }}
          <span style="font-size: 14px">积分</span>
        </div>
        <!-- <div class="boc-item1">
          <div class="fons1">今日订单数</div>
          <div class="tag">10单</div>
        </div> -->
      </el-card>
      <el-card class="a1" v-if="!user.roles.includes('biz_supplier_admin')">
        <div class="boc-item">
          <div class="fons">券码数</div>
          <div class="tag">
            <el-tag class="cc" size="mini"> 全平台</el-tag>
          </div>
        </div>
        <div class="box-it">{{ couponNum }}</div>
        <!-- <div class="boc-item1">
          <div class="fons1">今日订单数</div>
          <div class="tag">10单</div>
        </div> -->
      </el-card>
    </div>
    <div class="zhongj" v-if="!user.roles.includes('biz_supplier_admin')">
      <el-card class="c1">
        <div class="hz">
          <!-- <img src="/src/assets/images/sp.png" alt="" /> -->
          <img src="../../assets/images/sp.png" alt="" />
        </div>
        <p>商品管理</p>
      </el-card>
      <el-card class="c1">
        <div class="hz">
          <img src="../../assets/images/dd.png" alt="" />
        </div>
        <p>订单管理</p>
      </el-card>
      <el-card class="c1">
        <div class="hz">
          <img src="../../assets/images/dinziq.png" alt="" />
        </div>
        <p>券码管理</p>
      </el-card>
    </div>
  </div>
</template>
<script>
import {
  showProductNum,
  showHomeOrderNum,
  showHomeCouponNum,
} from "@/api/mallIndex";
export default {
  name: "MallIndex",
  data() {
    return {
      productNum: "",
      orderNum: "",
      orderMoney: "",
      jifenAmountTotal: "",
      couponNum: "",
    };
  },
  mounted() {
    this.getProductNum();
    this.getOrderNum();
    this.getCouponNum();
    console.log(this.$store.state.user);
  },
  computed: {
    user() {
      return this.$store.state.user;
    },
  },
  methods: {
    getProductNum() {
      showProductNum().then((res) => {
        this.productNum = res.data;
      });
    },
    getOrderNum() {
      showHomeOrderNum().then((res) => {
        this.orderNum = res.data.orderNum;
        this.orderMoney = res.data.moneyAmountTotal;
        this.jifenAmountTotal = res.data.jifenAmountTotal;
      });
    },
    getCouponNum() {
      showHomeCouponNum().then((res) => {
        this.couponNum = res.data.couponNum;
      });
    },
  },
};
</script>
<style scoped lang="scss">
.box {
  margin: 10px 20px;
  display: flex;
  justify-content: flex-start;

  .a1 {
    width: 24%;
    // margin-right: 20px;
    .boc-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .fons {
        font-size: 12px;
      }
    }
    .boc-item1 {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 17px;
      .fons1 {
        font-size: 14px;
      }
      .tag {
        font-size: 12px;
      }
    }
    .box-it {
      margin-top: 16px;
      border-top: 1px solid #eaeaea;
      border-bottom: 1px solid #eaeaea;
      padding: 18px 0;
      font-size: 26px;
    }
  }
}
.zhongj {
  margin: 0 20px 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .c1 {
    width: 33%;
    .hz {
      width: 100px;
      height: 100px;

      margin: 14px auto;
      // background-color: aqua;
      img {
        width: 100%;
        height: 100px;
      }
    }
    p {
      text-align: center;
    }
  }
}
</style>
